package projectsupporter.common.operation;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;

import dbTools.DBToolEngine;

import projectsupporter.common.logic.GlobalInfo;
import projectsupporter.common.logic.PlugLogic;
import projectsupporter.form.MainForm;

public class ImportBaseOperation implements IRunnableWithProgress{

	
	private MainForm form;

	public ImportBaseOperation(MainForm form) {
		this.form=form;
	}

	
	@Override
	public void run(IProgressMonitor monitor) throws InvocationTargetException,
			InterruptedException {
		
		monitor.beginTask("Loding table info", PlugLogic.BASE_CODE_COPY_LIST.size()*10);
		
		for (String path : PlugLogic.BASE_CODE_COPY_LIST) {
			monitor.subTask(path);
			PlugLogic.copyFolder(path, path.replace(GlobalInfo.BASE_ID,GlobalInfo.PRJ_NAME));
			monitor.worked(10);
		}
	    monitor.done();
		
		form.getsShell().getDisplay().asyncExec(new Runnable() {
			public void run() {

				form.initPrjInfo();

			}
		});
	    
	}

}
